# utils/pdf_generator.py
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def generate_pdf(problems):
    c = canvas.Canvas("math_problems.pdf", pagesize=letter)
    c.setFont("Helvetica", 12)
    x = 72
    y = 750
    for problem in problems:
        c.drawString(x, y, problem)
        y -= 20
        if y < 72:
            c.showPage()
            y = 750
    c.save()
    with open("math_problems.pdf", "rb") as f:
        pdf_data = f.read()
    return pdf_data
